home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / security / crack_4.1-tar / Scripts / Crack.network < prev    next >
Encoding:
Text File  |  1992-06-25  |  3.7 KB  |  201 lines

  1. #!/bin/sh
  2.  
  3. ###
  4. # This program is copyright Alec Muffett 1991, and is provided as part of
  5. # the Crack v4.0 Password Cracking package.  The author disclaims all
  6. # responsibility or liability with respect to it's usage or its effect
  7. # upon hardware or computer systems, and maintains copyright as set out in
  8. # the "LICENCE" document which accompanies distributions of Crack v4.0 and
  9. # upwards. So there...
  10. ###
  11. # This program reads the network.conf and breaks up the sorted password
  12. # file and runs RCrack to kick Crack up on all the machines and feeds 
  13. # the file to it.
  14. ###
  15. # Okay, if you don't like this bit of code, YOU think of a totally
  16. # portable way to do this - in shell scripts without using PERL - Alec.
  17. ###
  18.  
  19. cf=Scripts/network.conf
  20. tf=/tmp/mcp.$$
  21.  
  22. ###
  23. # Check that the config file is in place
  24. ###
  25.  
  26. if [ ! -f $cf -o ! -s $cf ]
  27. then
  28.     echo "Crack.network: empty or missing config file: $cf"
  29.     exit 1
  30. fi
  31.  
  32. ###
  33. # Parse arguments
  34. ###
  35.  
  36. args=""
  37. files=""
  38. domail=""
  39.  
  40. for i in $*
  41. do
  42.     if [ -f "$i" ]
  43.     then
  44.         files="$files $i"
  45.     else
  46.         case $i in
  47.             -f*)
  48.                 echo "Crack: -f option on COMMAND LINE incompatible with networking - Ignored"
  49.                 ;;
  50.             -m*)
  51.                 domail="$i"
  52.                 args="$args $i"
  53.                 ;;
  54.             *)
  55.                 args="$args $i"
  56.                 ;;
  57.         esac
  58.     fi
  59. done
  60.  
  61. ###
  62. # Get on with your proper job
  63. ###
  64.  
  65. echo "Merging input data."
  66.  
  67. if [ "$CRACK_OUT" != "" ]
  68. then
  69.     warn=$CRACK_OUT/out.$$
  70. else
  71.     warn=out.$$
  72. fi
  73.  
  74. Scripts/do_join $warn $files > $tf
  75.  
  76. if [ "x$domail" != "x" ]
  77. then
  78.     MISCREANTS=`awk '/Guessed/{print $6}' < $warn`
  79.     echo Sending Warning Mail to $MISCREANTS
  80.     Scripts/nastygram $MISCREANTS
  81. fi
  82.  
  83. ###
  84. # Statistics gathering
  85. ###
  86.  
  87. lines=`wc -l < $tf`
  88. saltlines=`Scripts/saltcount < $tf`
  89.  
  90. # Must not quote $lines/$saltlines here for comparison to work
  91. if [ $lines = 0 -o $saltlines = 0 ]
  92. then
  93.     echo "Crack: no uncracked input to distribute."
  94.     exit 1
  95. fi
  96.  
  97. echo "Starting analysis for Network-Crack."
  98.  
  99. cat $cf |
  100. grep -v '^#' |
  101. grep -v '^$' |
  102. sort -t: +2 -n |
  103. awk -F: '
  104. BEGIN {
  105.     hostcount = 0;
  106.     totalweight = 0;
  107.     linecount = '"$lines"';
  108.     saltlinecount = '"$saltlines"';
  109.     iargs = "'"$args"'";
  110.     file = "'"$tf"'";
  111. }
  112.  
  113. /^[a-zA-Z0-9]/ {
  114.     hostname[hostcount] = $1;
  115.     bintype[hostcount] = $2;
  116.     relpow[hostcount] = $3;
  117.     powtot += $3;
  118.  
  119.     if (index($6, "-f") == 0)
  120.     {
  121.         asynch[hostcount] = "";
  122.     } else
  123.     {
  124.         asynch[hostcount] = "-asynch";
  125.     }
  126.  
  127.     crackf[hostcount] = $6 " " iargs;  # useropts go second get priority
  128.  
  129.     if ($4 == "")
  130.     {
  131.         rshuser[hostcount] = "";
  132.     } else
  133.     {
  134.         rshuser[hostcount] = "-l " $4;
  135.         crackf[hostcount] = crackf[hostcount] " -U" $4;
  136.     }
  137.  
  138.     if ($5 == "")
  139.     {
  140.         crackp[hostcount] = "$CRACK_HOME_UNRES/Crack";
  141.     } else
  142.     {
  143.         crackp[hostcount] = $5;
  144.     }
  145.  
  146.     crackf[hostcount] = iargs " " $6;
  147.     hostcount++;
  148. }
  149.  
  150. END {
  151.     done = 1;
  152.     slice = 0.0;
  153.     remainder = 0.0;
  154.     todo = saltlinecount;
  155.     print "echo Users:", linecount;
  156.     print "echo Salts:", saltlinecount;
  157.     print "echo Remote Hosts:", hostcount;
  158.     print "echo Total power:", powtot;
  159.  
  160.     for (i = 0; i < hostcount; i++)
  161.     {
  162.         if (i < hostcount - 1)
  163.         {
  164. # This balancing algorithm by: george@au.edu.monash.cc.moa (George Scott)
  165. # its wonderful - AEM
  166.             slice = relpow[i] / powtot;        # fraction
  167.             slice *= todo;                # percentage
  168.             slice = int(slice);            # round down
  169.             todo -= slice;                # remainder
  170.             powtot -= relpow[i];
  171.         } else
  172.         {
  173.             slice = todo;    # fastest machine gets the rest.
  174.             todo = 0;
  175.         }
  176.         if (slice > 0)
  177.         {
  178.             print "echo Calling", hostname[i], "for", slice, "different salts";
  179.  
  180.             line = sprintf( \
  181.        "Scripts/RCrack %s %d %d %s %s \"%s\" %s %s %s < %s", \
  182.                 asynch[i], \
  183.                 done, \
  184.                 done + slice - 1, \
  185.                 hostname[i], \
  186.                 rshuser[i], \
  187.                 crackp[i], \
  188.                 "-XRuntime/RD'"$$"'." i, \
  189.                 crackf[i], \
  190.                 bintype[i], \
  191.                 file);
  192. #            print "echo", line;
  193.             print line;
  194.         }
  195.         done += slice;
  196.     }
  197. }' | sh        # I'll bet you didn't expect this...
  198.  
  199. rm $tf
  200. exit 0
  201.